package com.bjmashibing.system.OSFileIO.io_demo.anotherStream;

import java.io.*;

/**
 * 用这个注意顺序，write和read的类型必须是一致的，bool->int ->double
 */
public class DataStream {
    public static void main(String[] args) throws IOException {
       demo1();
    }

    public static void demo1() throws IOException {
        FileInputStream inputStream = new FileInputStream("src/Java_IO/io_demo/Resources/abc.txt");
        FileOutputStream outputStream = new FileOutputStream("src/Java_IO/io_demo/Resources/abc.txt");
        DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
        DataInputStream dataInputStream = new DataInputStream(inputStream);

        dataOutputStream.writeBoolean(true);
        dataOutputStream.writeInt(123);
        dataOutputStream.writeDouble(3.14);

        System.out.println(dataInputStream.readBoolean());
        System.out.println(dataInputStream.readInt());
        System.out.println(dataInputStream.readDouble());
    }

}
